

use "$temp/nlsy_base_sample_inc", clear

drop enroll* hgc*
//reshape to long
reshape long hideg_ income_ weight_ hours_, i(uniqid) j(year)

******deflate stuff***********
merge m:1 year using "$data/GDP/gdp_pce_deflator", keep(match) nogen
replace deflator = deflator/100 //normalize
replace income = income/deflator //deflate labor income

gen deflator_1968 = 19.152 //1968 deflator
gen inc_1968 = income*(deflator_1968/100)
gen age = year - birthyr

drop if age>30 & (hours<520 | inc_1968<1500) //adequate work for older heads
drop if age<=30 & (hours<260 | inc_1968<1000) 
//keep if race == 4

replace income = income/40000

gen linc = log(income)

//generate age variable in preparation for reshaping
drop year sample sex race 
sort uniqid age

//highest educational attainment by age 28
gen deg_type = 0
replace deg_type = 1 if hideg == 1 | hideg == 2
replace deg_type = 2 if hideg == 3
replace deg_type = 3 if hideg == 4
replace deg_type = 4 if (hideg>4 & hideg!=.)
replace deg_type = 0 if age>28

bys uniqid: egen max_deg = max(deg_type)
drop if max_deg == 0 | max_deg == 4


gen x = age-19
replace x = age-21 if max_deg == 2
replace x = age-23 if max_deg == 3

keep if age>=24 & age<=34

reg linc ability_pct [w=weight] if max_deg == 1 
reg linc ability_pct [w=weight] if max_deg == 2
reg linc ability_pct [w=weight] if max_deg == 3


//let's target wage ratios b/t high/low ability instead of wage levels. That way we won't be 
//targeting two different sets of earnings moments/nlsy_wage_profiles
collapse (mean) income [w=weight], by(age max_deg ability)
reshape wide income_, i(age max_deg) j(ability)
gen ratio_ = income_3 / income_1
drop income_*
reshape wide ratio, i(age) j(max_deg)

collapse (mean) ratio*
xpose, clear
export delimited "$model/moments/nlsy_wage_ratios.csv", novarn replace



/*
//collapse to get some age profiles
collapse (mean) income [w=weight], by(age max_deg ability)
replace income = round(income, 0.01)

reshape wide income_, i(age ability) j(max_deg)
sort ability age

collapse (mean) ratio*


exit

export delimited "$model/moments/nlsy_wage_profiles.csv", novarn replace

*/


//

